<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>023-求和.html</title>
</head>
<body>
	<input type="text" id="txt1">
	<input type="text" id="txt2">
	<input type="button" id="btn" value="求和">
</body>
<script>
	var oTxt1 =document.getElementById('txt1');
	var oTxt2 =document.getElementById('txt2');
	var oBtn =document.getElementById('btn');

	// console.log(oTxt1);
	// console.log(oTxt2);
	// console.log(oBtn);

	oBtn.onclick = function(){
		// alert(oTxt1.value);
		var Val1 =parseInt(oTxt1.value);
		var Val2 =parseInt(oTxt2.value);

		// alert(typeof oVal1);
		// NaN=>not a number;
		// alert(1 == 1);
		// alert(oVal1 == NaN);
		// alert(isNaN(1));
		if(isNaN(Val1)){
			alert("请在第一个输入框输入正确的数字");
		}else if(isNaN(Val2)){
			alert("请在第二个输入框输入正确的数字");
		}else{
			alert(Val1 + Val2);
		}
		

		// alert(oVal1 + oVal2);
	}
</script>
</html>